#ifndef _PIANO_PROGRAM_H_
#define _PIANO_PROGRAM_H_

#include <ne.h>
#include <Game/Game.h>
#include <NoteRenderer.h>

namespace pp
{
    class PianoProgram : public ne::Singleton<PianoProgram>, public ne::Resource::Listener
    {
        public:
            PianoProgram(int argc, char *argv[]);

            void init();

            void start();

            bool tick();

            bool render();

            virtual void onBackgroundThreadLoadingComplete(ne::Resource *pResource);

            virtual ~PianoProgram();

        public:
            static void* LoadSequence(void *arg);

            static void MainLoop();

            static void Display();

            static PianoProgram& GetSingleton();

            static PianoProgram* GetSingletonPtr();

        public:
            static ne::GlutApplication *application;
            static ne::Engine *engine;
            static ne::Keyboard *keyboard;
            static Game *game;
            ne::MIDISequencePtr mpSequence;

        private:
            ne::Timer *mpTimer;
            ne::MIDIInDevice *mpMIDIInDevice;
            ne::MIDIPlayer *mpMIDIPlayer;
            std::string mSequenceFileName;
            std::map<ne::byte, bool> mKeyMap;
            NoteRenderer *mpNoteRenderer;
            ne::Thread *mpLoadThread;
            float mLoading;
            int mArg;
    };
}

#endif
